package com.mk.admin.service.impl;

import com.mk.admin.mapper.DoctorOnlineSchedulingMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.DoctorOnlineSchedulingEntity;
import com.mk.admin.model.query.DoctorOnlineSchedulingQuery;
import com.mk.admin.model.vo.DoctorOnlineSchedulingVo;
import com.mk.admin.service.DoctorOnlineSchedulingService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorOnlineSchedulingServiceImpl implements DoctorOnlineSchedulingService {
    @Autowired
    private DoctorOnlineSchedulingMapper doctorOnlineSchedulingMapper;

    @Override
    public ResultDto select(DoctorOnlineSchedulingQuery query) {
        DoctorOnlineSchedulingEntity entity = JSONCopy.copy(query, DoctorOnlineSchedulingEntity.class);

        return ResultDto.data(doctorOnlineSchedulingMapper.count(entity), doctorOnlineSchedulingMapper.select(entity));
    }

    @Override
    public ResultDto add(DoctorOnlineSchedulingVo doctorOnlineSchedulingVo) {
        return ResultDto.data(doctorOnlineSchedulingMapper.insert(JSONCopy.copy(doctorOnlineSchedulingVo, DoctorOnlineSchedulingEntity.class)));
    }

    @Override
    public ResultDto update(DoctorOnlineSchedulingVo doctorOnlineSchedulingVo) {
        return ResultDto.data(doctorOnlineSchedulingMapper.updateById(JSONCopy.copy(doctorOnlineSchedulingVo, DoctorOnlineSchedulingEntity.class)));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(doctorOnlineSchedulingMapper.deleteById(id));
    }


    @Override
    public ResultDto status(int id) {
        return ResultDto.data(doctorOnlineSchedulingMapper.status(id));
    }
}
